package com.apes.scm.stock.transfer.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.stock.transfer.model.ConsumableUse;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.Map;

/**
 * 功能：
 ***
 * @author zhuyh
 * @time 11:48
 * @date 2019/11/21
 */
public interface ConsumableUseRepository extends CustomRepository<ConsumableUse,String> {


    @Query("select sum(p.useQty) as useQty from ConsumableUseItem p where p.consumableUse.location.depot.dept.id = :deptId " +
            "and p.consumableUse.state = 'done' and p.consumableUse.dateDone > :startDate and p.consumableUse.dateDone < :endDate ")
    Map<String, Object> findDone(@Param("deptId") String deptId, Date startDate, Date endDate);

}
